from socket import *

serSocket = socket(AF_INET,SOCK_STREAM)
localAddr = ("",7788)
serSocket.bind(localAddr)
serSocket.listen(5)

while True:
    newSocket,destAddr = serSocket.accept()
    try:
        while True:
            recvData = newSocket.recv(1024)
            if len(recvData) > 0:
                print("%s的信息为%s"%(str(destAddr),recvData))
            else:
                print("%s客户端已经关闭"%destAddr)
                break
    finally:
        newSocket.close()
serSocket.close()